package com.etlmaster.executor.agent;

import com.etlmaster.executor.scheduler.Proc;
import com.etlmaster.executor.scheduler.utils.CallRunLocalCmd;
import com.etlmaster.executor.scheduler.utils.SubmitResult;
import com.etlmaster.executor.utils.DataCollectionUtils;
import com.etlmaster.executor.utils.MultiProcessHelper;

/**
 * @author Larry
 * @copyright Larry@etlMaster
 * @since 2017-09-10
 */
public class DefaultAgent extends Agents{

	public DefaultAgent(String id,String host, int maxThreadNum) {
		super(id,host, maxThreadNum);
		// TODO Auto-generated constructor stub
	}

	@Override
	public SubmitResult run(Proc proc) {
		String localCmd=DataCollectionUtils.getProperties("runLocalCmdPath")+proc.getRunParam();

		SubmitResult result=new SubmitResult();

		CallRunLocalCmd entity = new CallRunLocalCmd(localCmd, this,proc);
		getRunningProcs().add(proc);
		result.setResult( MultiProcessHelper.executor.submit(entity));
		return result;
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}

}
